﻿var highlightcolor = '#c1ebff';
//此处clickcolor只能用win系统颜色代码才能成功,如果用#xxxxxx的代码就不行,还没搞清楚为什么:(
var clickcolor = '#51b2f6';
function changeto(ev) {

    //火狐中是ev.target
    source = ev.srcElement?ev.srcElement:ev.target;

    if (source.tagName.toLowerCase() == "tr" || source.tagName.toLowerCase() == "table")
        return;

    while (source.tagName.toLowerCase() != "td")
        source = source.parentElement ? source.parentElement : source.parentNode;

    source = source.parentElement ? source.parentElement : source.parentNode;

    cs = source.children;
    //alert(cs.length);
    if (cs[1].style.backgroundColor != highlightcolor && source.id != "nc" && cs[1].style.backgroundColor != clickcolor)
        for (i = 0; i < cs.length; i++)
        {
            cs[i].style.backgroundColor = highlightcolor;
        }
}

function changeback(ev) {

    //火狐中是ev.target
    source = ev.srcElement ? ev.srcElement : ev.target;

    if (source.tagName.toLowerCase() == "tr" || source.tagName.toLowerCase() == "table")
        return;

    while (source.tagName.toLowerCase() != "td")
        source = source.parentElement ? source.parentElement : source.parentNode;

    source = source.parentElement ? source.parentElement : source.parentNode;

    cs = source.children;
    //if (ev.fromElement.contains(ev.toElement)|| source.contains(ev.toElement) || source.id == "nc")
       // return;
    if (ev.toElement != source && cs[1].style.backgroundColor != clickcolor)
        for (i = 0; i < cs.length; i++)
        {
            cs[i].style.backgroundColor = "";
        }
}

function clickto()
{
    source = event.srcElement;
    if (source.tagName.toLowerCase() == "tr" || source.tagName.toLowerCase() == "table")
        return;
    while (source.tagName.toLowerCase() != "td")
        source = source.parentElement;
    source = source.parentElement;
    cs = source.children;
    //alert(cs.length);
    if (cs[1].style.backgroundColor != clickcolor && source.id != "nc")
        for (i = 0; i < cs.length; i++)
        {
            cs[i].style.backgroundColor = clickcolor;
        }
    else
        for (i = 0; i < cs.length; i++)
        {
            cs[i].style.backgroundColor = "";
        }
}